package com.tj.bo.account.server.dao.impl;

import com.fqgj.common.api.Page;
import com.fqgj.common.base.AbstractBaseMapper;
import com.tj.bo.account.server.dao.AccountFlowDao;
import com.tj.bo.account.server.entity.AccountFlowEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* User: account
* Date: 2020-06-10
* Time: 14:40:36.633
*/

@Repository
public class AccountFlowDaoImpl extends AbstractBaseMapper<AccountFlowEntity> implements AccountFlowDao {

    @Override
    public List<AccountFlowEntity> getAccountFlowByOrderNoAndType(String orderNo, String type) {
        Map<String, Object> params = new HashMap<>();
        params.put("orderNo", orderNo);
        params.put("type", type);
        return getSqlSession().selectList(getStatement("getAccountFlowByOrderNoAndType"), params);
    }

    @Override
    public List<AccountFlowEntity> getAccountFlowByTypeAndAmountType(String userCode, String type, List<String> subTypeList, Integer amountType, Page page) {

        Map<String, Object> params = new HashMap<>();
        params.put("page", page);
        params.put("userCode", userCode);
        params.put("type", type);
        params.put("subTypeList", subTypeList);
        params.put("amountType", amountType);
        page.setTotalCount(getSqlSession().selectOne("countAccountFlow", params));
        return getSqlSession().selectList(getStatement("getAccountFlowByTypeAndAmountType"), params);
    }

    @Override
    public Integer countAccountFlow(String userCode, String type, List<String> subTypeList, Integer amountType) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        params.put("type", type);
        params.put("subTypeList", subTypeList);
        params.put("amountType", amountType);
        return getSqlSession().selectOne(getStatement("countAccountFlow"), params);
    }
}